# Contributor: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
# Maintainer: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
pkgname=py3-imbalanced-learn
_pkgorig=imbalanced-learn
pkgver=0.12.2
pkgrel=1
pkgdesc="Toolbox for imbalanced dataset in machine learning"
url="https://imbalanced-learn.org"
arch="noarch"
license="MIT"
depends="
	py3-numpy
	py3-pandas
	py3-scikit-learn
	py3-scipy
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="
	py3-pytest-xdist
	"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://files.pythonhosted.org/packages/source/i/imbalanced-learn/imbalanced-learn-$pkgver.tar.gz
	exclude-tests.patch"
builddir="$srcdir/$_pkgorig-$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl

	local skipped_tests="
		test_all_estimators
		and not test_classification_report_imbalanced_multiclass_with_unicode_label
		and not test_rusboost
		and not test_cluster_centroids_n_jobs
		and not test_fit_docstring
		and not keras
		and not test_function_sampler_validate
		and not test_fetch
		and not check_samplers_preserve_dtype
		and not test_pipeline_fit_then_sample_with_sampler_last_estimator
		and not test_pipeline_fit_then_sample_3_samplers_with_sampler_last_estimator"

	# shellcheck disable=SC2116
	.testenv/bin/python3 -m pytest -k "not $(echo $skipped_tests)" -n auto
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
b6df85331b9df67f9e8d7ae83ed78bb45e05889ae3281d66a045c45e8759ffcd8841ffd54071f1d7aba8c3841ca8e06698438b92e3b7f2b3e6412e90c63ac12a  py3-imbalanced-learn-0.12.2.tar.gz
57a181476c728451b4c54ae535d0f236ac7228b525c8dcbe118bfc8837f1f270fd8185beef59dcbf8fe9c12a67af9c4064339de5df1caf18743c1a4c475db9b0  exclude-tests.patch
"
